package Singleton;

public class LazyManDCL {
    private static volatile LazyManDCL instance = null; // volatile禁止指令重排

    private LazyManDCL() {}

    public static LazyManDCL getInstance() {
        if (instance == null) { // 第一次判空，减少锁竞争
            synchronized (LazyManDCL.class) {
                if (instance == null) { // 第二次判空，保证单例
                    instance = new LazyManDCL();
                }
            }
        }
        return instance;
    }
}
